package com.unbank.bhi.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.log4j.Logger;

public class BhiJDBC {
	static Connection conn = null;
	private final static Logger logger = Logger.getLogger(BhiJDBC.class);

	public static Connection getConn() {

		if (conn == null) {
			try {
				Class.forName("com.mysql.jdbc.Driver");
				conn = DriverManager.getConnection(
						"jdbc:mysql://10.0.2.26:3307/callitnew", "user",
						"123456");
				return conn;
			} catch (Exception e) {
				logger.error("连接数据库失败");
			}
		} else {
			return conn;
		}

		return conn;
	}

	public static void close() {
		if (conn != null) {
			try {
				conn.close();
			} catch (SQLException e) {
				logger.error("关闭数据库链接失败");
			}
		}
	}
}
